package com.woniuxy.gobang.ui;

import java.util.List;

import dao.BattleDataDAO;
import entity.Battle;
import exception.DAOException;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class RecordStage extends Stage {
	
	public RecordStage() {
		setTitle("历史战绩");
		Pane pane = new Pane();
		Scene scene = new Scene(pane, 700,300);		
		setResizable(false);
		setScene(scene);
			
		TextArea recode = new TextArea();
		recode.setPrefSize(700,300);
		recode.setLayoutX(0);
		recode.setLayoutY(0);
		try{
			String str="";
			BattleDataDAO battledao = new BattleDataDAO();
			List<Battle> ls=battledao.getRecordByAccount(Global.user.getAccount());
			for (Battle mr : ls) {
				str+=mr.toString()+"\n";
			}
			recode.setText(str);	
			pane.getChildren().add(recode);
			show();
		}catch(DAOException e){
			// 创建提示框
			Alert alert = new Alert(AlertType.ERROR);
			alert.setContentText("系统维护中！");
			alert.setTitle("错误");
			alert.show();
		}
	}

}
